package com.chefu.admin.controller;

import com.chefu.admin.pojo.ServiceProvider;
import com.chefu.admin.pojo.mongo.ServerProLocation;
import com.chefu.admin.service.PositionService;
import com.chefu.common.constants.CfConstants;
import com.chefu.common.pojo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@RestController
public class PositionController {

    @Autowired
    private PositionService positionService;

    @PostMapping("/serverPro/location")
    public R saveServerProLocation(@RequestBody ServiceProvider serviceProvider){
        positionService.saveServerProLocation(serviceProvider);
        return R.ok();
    }

    @GetMapping("/serverPro/near")
    public R getNearServerPro(HttpServletRequest request){
        List<ServerProLocation> serverProLocationList = positionService.getNearServerPro(request);
        return R.ok().data("nearServerProList",serverProLocationList);
    }
}
